package org.linloong.modules.apis.monitor.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 多传感器带单位的月度数据格式
 */
@Data
@Schema(name = "MultiSensorWithUnitAggDTO", description = "按年份分组的多传感器月度数据（含单位）")
public class MultiSensorWithUnitAggDTO {
    @Schema(description = "年份", example = "2025")
    private Integer year;

    @Schema(description = "月度数据列表")
    private List<MonthSensorData> data = new ArrayList<>();

    /**
     * 月度数据项（含多个传感器）
     */
    @Data
    @NoArgsConstructor
    public static class MonthSensorData {
        @Schema(description = "月份（字符串）", example = "10")
        private String month;

        @Schema(description = "传感器数据列表（同月份下的多个传感器）")
        private List<SensorData> sensor = new ArrayList<>();

        public MonthSensorData(String month) {
            this.month = month;
        }
    }

    /**
     * 单个传感器数据（含单位）
     */
    @Data
    @NoArgsConstructor
    public static class SensorData {
        @Schema(description = "传感器名称", example = "温度")
        private String name;

        @Schema(description = "平均值（字符串）", example = "8.00")
        private String value;

        @Schema(description = "单位", example = "°C")
        private String unit;

        public SensorData(String name, String value, String unit) {
            this.name = name;
            this.value = value;
            this.unit = unit;
        }
    }
}